﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.ColorSystemTableAdapters;
using DAL;
using DAL.DateSet;
namespace BLL.Wrapper
{
    public class ColorSystemWrapper : ColorSystemTableAdapter
    {
        public ColorSystem.ColorSystemDataTable getall()
        {
            return GetData();
        }

        public void addARecord(ColorSystem.ColorSystemRow row)
        {
            Insert(row.colorSystemName, row.colorSystemNum, row.colorSysCreator, row.colorSysCreateDate);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from ColorSystem where colorSystemID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(ColorSystem.ColorSystemRow row)
        {
            ColorSystem.ColorSystemDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["colorSystemID"]) == row.colorSystemID)
                {
                    table.Rows[i]["colorSystemName"] = row.colorSystemName;
                    table.Rows[i]["colorSystemNum"] = row.colorSystemNum;
                    table.Rows[i]["colorSysCreator"] = row.colorSysCreator;
                    table.Rows[i]["colorSysCreateDate"] = row.colorSysCreateDate;
                    break;
                }
            }
            Update(table);
        }
    }
}
